<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="../../css/demo.css" />
    
    <title>Jslet - DBSpinEdit</title>
    <script type="text/javascript" data-main="../../config.js" src="../../lib/requirejs/require.min.js"></script>
    <script type="text/javascript">
	    require(['dbcontrol/form/a-dbspinedit']);
    </script>
</head>
<body>
    <div class="demo-header">
    <h4 id="top">Jslet - DBSpinEdit</h4>
	</div>
	<hr />

	<div data-jslet="type: 'DBTable', dataset: 'employee'" style="margin-bottom: 10px"></div>
	
	<div class="container-fluid">
	<div class="form-horizontal">
	<div class="form-group form-group-sm" style="vertical-align: middle">
	<div class="col-sm-2">
		<label>步长为1(缺省)</label>
	</div>
	<div class="col-sm-2">
		<div data-jslet="type: 'DBSpinEdit', dataset: 'employee', field: 'salary'"></div>
	</div>
	<div class="col-sm-2">
		<label>步长为1000</label>
	</div>
	<div class="col-sm-2">
		<div data-jslet="type: 'DBSpinEdit', dataset: 'employee', field: 'salary', step: 1000"></div>
	</div>
	</div>

	</div>
	</div>
	<p><button id="btnSetDataRange" class="btn btn-default btn-sm">设置最大最小值(1000, 10000)</button></p>
	
	<hr />
	<h4>源码</h4>
	<h5>HTML</h5>
    <pre class="prettyprint linenums"><code>
    //步长为1(缺省)
    &lt;div data-jslet="type: 'DBSpinEdit', dataset: 'employee', field: 'salary'">&lt;/div>
    
   	// 步长为1000
    &lt;div data-jslet="type: 'DBSpinEdit', dataset: 'employee', field: 'salary', step: 1000">&lt;/div>
    
	</code></pre>
    
	<h5>JavaScript</h5>
    <pre class="prettyprint linenums"><code>
	//datasetMetaStore定义在公共js:common/datasetmetastore.js中
	//将数据集定义信息仓库加到datasetFactory中，创建Dataset时会仓库里去定义信息
	jslet.data.datasetFactory.addMetaStore(window.datasetMetaStore);
	//通过工厂方法，可以自动创建主数据集及相关的数据集
    jslet.data.datasetFactory.createDataset('employee').done(function() {
    	jslet.data.getDataset('employee').query();
    	jslet.ui.install();
    });
    
    //设置最大最小值(1000, 10000)
    $('#btnSetDataRange').click(function() {
    	var dsEmployee = jslet.data.getDataset('employee');
    	//设置字段对象的dataRange属性即可
    	dsEmployee.getField('salary').dataRange({min: 1000, max: 10000})
    });
	</code></pre>

    <script type="text/javascript">
       window.LOADER_BASE_URL = "../../lib/prettify";
    </script>
    <script type="text/javascript" src="../../lib/prettify/run_prettify.js"></script>
		
</body>
</html>
